#!/usr/bin/env python
#encoding=utf8
"""
@描述:集中计算hash的经典方法
@日期:2015年02月08日 星期日

@作者:hongxingfan
@参考:http://www.cnitblog.com/schkui/archive/2007/07/02/29320.html
"""

def rsHash(string):
	a = 63689
	b = 378551
	hsh = 0
	for s in string:
		hsh = hsh * a + ord(s) # 字符的asc码,还有chr将字符转化成数字
		a *= b
	return hsh & 0x7fffffffffffffff # python的int是64个字节


if __name__ == "__main__":
	string = "hongxingfan"
	hsh = rsHash(string)
	print(hsh)
